package com.hyacinth.cloudnote.modules.note.repository;

import com.hyacinth.cloudnote.modules.note.model.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.Repository;

import java.util.Optional;
import java.util.UUID;

/**
 * User实体类对应的基础业务Repository
 */
@org.springframework.stereotype.Repository
public interface UserRepository extends Repository<User, UUID> {

    User save(User model);

    Optional<User> findById(UUID id);

    Page<User> findAll(Pageable pageable);

    Optional<User> findByUsernameOrMobileOrEmail(String username, String mobile, String email);

    boolean existsByMobile(String mobile);

    boolean existsByMobileAndIdNot(String mobile, UUID id);

    boolean existsByUsername(String username);

    boolean existsByUsernameAndIdNot(String username, UUID id);

    boolean existsByEmail(String email);

    boolean existsByEmailAndIdNot(String email, UUID id);
}
